
package modelo.bo.session;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class SessionManager {
	//private HttpServletRequest request;

	public static HttpSession getCurrentSession(HttpServletRequest request) {
		HttpSession session = request.getSession(false);				
		
		if(session == null) {
			session =  request.getSession();
			System.out.println("Sessao criada ID: "+session.getId());			
		}
/*		else {
			System.out.println("ID existente: "+session.getId());			
		}*/
		
		return session;
	}
	
	public static void encerrarSessionAtual(HttpSession session, String nomeAtributo) {
				
		if(session.getAttribute(nomeAtributo) != null) {
			session.invalidate();
		}
		
	}
		
/*	public static void configTempMaxInativo(HttpSession session, int minutos) {
		
		if(session != null) {
			session.setMaxInactiveInterval(minutos * 60);			
		}
		
	}
	*/			
}



